class Solution:
    def rearrangeCharacters(self, s: str, target: str) -> int:
        char_dict = {}
        for i in s:
            if char_dict.get(i):
                char_dict[i] +=1
            else:
                char_dict[i] = 1
        print(char_dict)
        target_dict = {}
        for i in target:
            if target_dict.get(i):
                target_dict[i] +=1
            else:
                target_dict[i] =1
        all_list = list()
        print( target_dict)
        for k,v in target_dict.items():
            if char_dict.get(k):
                all_list.append(char_dict[k]//v)
            else:
                return 0
        return min(all_list)
       # return min(target_char_list)



if __name__ == '__main__':
    s = "abbaccaddaeea"
    target = "aaaaa"
    solution = Solution()
    val = solution.rearrangeCharacters(s,target)
    print(val)